package com.java01.apache.commons.config;

import java.io.File;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.HierarchicalINIConfiguration;
import org.apache.commons.configuration.SubnodeConfiguration;
import org.apache.commons.configuration.HierarchicalConfiguration.Node;

public class LoadIniConfig {

	public static void main(String[] args) throws ConfigurationException{
		File configFile = new File("C:\\config.ini");
		HierarchicalINIConfiguration iniConfig = new HierarchicalINIConfiguration();
		iniConfig.load(configFile);

		for(Object secObj:iniConfig.getSections()){
			SubnodeConfiguration subNode=iniConfig.getSection(secObj.toString());
			System.out.println("----"+secObj.toString()+"----");
			if(subNode!=null){
				for(Object obj:subNode.getRootNode().getChildren()){
					Node node = (Node)obj;
					System.out.println(node.getName()+" = "+node.getValue());
				}
			}
		}
	}
}